﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Chapter05
{
    using Chapter05.View;

    /// <summary>
    /// 第5章 路由事件
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            #region 01 理解路由事件
            /*
             * 01 定义、注册和封装路由事件
             * 02 共享路由事件
             * 03 引发路由事件
             * 04 处理路由事件
             * */
            #endregion

            #region 02 事件路由
            /*
             * 01 RoutedEventArgs 类
             * 02 冒泡路由事件
             * 03 处理挂起的事件
             * 04 附加事件
             * 05 隧道路由事件
             * */
            #endregion

            #region 03 WPF 事件
            /*
             * 01 生命周期事件
             * 02 输入事件
             * */
            #endregion

            #region 04 键盘输入
            /*
             * 01 处理按键事件
             * 02 焦点
             * 03 获取键盘状态
             * */
            #endregion

            #region 05 鼠标输入
            /*
             * 01 鼠标单击
             * 02 捕获鼠标
             * 03 鼠标拖放
             * */
            #endregion

            #region 06 多点触控输入
            /*
             * 01 多点触控的输入层次
             * 02 原始触控
             * 03 操作
             * 04 惯性
             * */
            #endregion

            #region 07 小结
            #endregion
        }

        private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (e.Command == ApplicationCommands.Open)
            {
                var button = e.Source as Button;
                if (button != null)
                {
                    if (button == button1)
                    {
                        var window = new BubbledLabelClickWindow();
                        Demo(window);
                    }
                    if (button == button2)
                    {
                        var window = new TunneledLabelClickWindow();
                        Demo(window);
                    }
                    if (button == button3)
                    {
                        var window = new KeyPressEventsWindow();
                        Demo(window);
                    }
                    if (button == button4)
                    {
                        var window = new MousePositionWindow();
                        Demo(window);
                    }
                    if (button == button5)
                    {
                        var window = new DragAndDropWindow();
                        Demo(window);
                    }
                }
            }
        }

        private void Demo(Window window)
        {
            window.Owner = this;
            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            window.ShowDialog();
        }
    }
}
